package zzj.campus_book_sharing_platform.Controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import zzj.campus_book_sharing_platform.Entity.Book;
import zzj.campus_book_sharing_platform.Service.BookService;
import zzj.campus_book_sharing_platform.uitl.ResultFormat;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * (Book)表控制层
 *
 * @author ZZJ
 * @since 2022-01-04 12:13:50
 */
@Tag(name = "实体书籍")
@RestController
@RequestMapping("book")
public class BookController {
    /**
     * 服务对象
     */
    @Resource
    private BookService service;

    /**
     * 条件查询
     *
     * @param book 筛选条件
     * @return 查询结果
     */
    @Operation(summary = "实体书籍-条件查询")
    @RequestMapping(value = "/queryAll",method = RequestMethod.GET)
    public ResultFormat queryAll(Book book, HttpSession session) {
        return this.service.queryAll(book,session);
    }


    /**
     * 新增数据
     *
     * @param book 实体
     * @return 新增结果
     */
    @Operation(summary = "实体书籍-新增")
    @RequestMapping(value = "/add",method = RequestMethod.GET)
    public ResultFormat add(Book book,HttpSession session) {
        return this.service.insert(book,session);
    }

    /**
     * 编辑数据
     *
     * @param book 实体
     * @return 编辑结果
     */
    @Operation(summary = "实体书籍-编辑数据")
    @RequestMapping(value = "/update",method = RequestMethod.GET)
    public ResultFormat update(Book book,HttpSession session) {
        return this.service.update(book,session);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @Operation(summary = "实体书籍-删除")
    @RequestMapping(value = "/deleteById",method = RequestMethod.GET)
    public ResultFormat deleteById(String id,HttpSession session) {
        return this.service.deleteById(id,session);
    }

}

